Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Google OAuth2 + react-google-login: "redirect_uri_mismatch" al intentar recuperar un token de actualización

¿como estas?

Estoy usando react-google-login para que el inicio de sesión fluya en la interfaz.

Esta es la configuración de mi botón de inicio de sesión:

 <GoogleLogin accessType="offline" clientId={google.client_id} cookiePolicy="single_host_origin" onSuccess={handleLogin} onFailure={handleLoginFail} prompt="consent" responseType="code" scope="email profile https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar.events.readonly openid" render={(_props) => ( <Button className="google-login-btn" onClick={_props.onClick}> {props.buttonText} <GoogleIcon className="google-icon" height="20px" width="20px" /> </Button> )}> </GoogleLogin>

Esto funciona bien y recibo con éxito un authorization_code de Google. El problema es cuando trato de obtener un token de actualización para el usuario.

Este es el código que estoy usando para recuperar el token de actualización:

 const { client_id, client_secret, redirect_uri } = require('../config').google; export async function GetRefreshToken(code) { try { const data = new URLSearchParams({ code, client_id, client_secret, grant_type: 'authorization_code', redirect_uri }); const headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; const response = await axios.post('https://oauth2.googleapis.com/token', data, { headers }); const parsedResponse = JSON.parse(response.data); if (parsedResponse.refresh_token) return parsedResponse; else return null; } catch (err) { console.error(err); throw err; } }

Y este es el error que estoy recibiendo:

 { "error": "redirect_uri_mismatch", "error_description": "Bad Request" }

Mi redirect_uri está configurado como http://localhost:3000/ y he confirmado que está configurado correctamente en mi proyecto de Google.

¿Que me estoy perdiendo aqui?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bien, finalmente encontré una solución.

Establecer el redirect_uri como postmessage funcionó.

¿Por qué? Todavía me pregunto... ¡Pero funciona!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!